package effectiveJava.throwble;

import java.io.IOException;

public class SuishoudaiException extends Exception {

    private static final long serialVersionUID = -3135631978168464885L;

    private Result result;

    public SuishoudaiException() {
        super("系统错误，请稍后重试");
    }

    public SuishoudaiException(Result result, String message, Throwable cause) {
        super(message, cause);
        this.result = result;
    }

    public SuishoudaiException(Result result, Throwable cause) {
        super(cause);
        this.result = result;
    }

    public SuishoudaiException(String message, Throwable cause) {
        super(message, cause);
    }

    public SuishoudaiException(Throwable cause) {
        super(cause);
    }

    public SuishoudaiException(String message) {
        super(message);
    }

    public SuishoudaiException(Result result) {
        this.result = result;
    }

    public Result getResult() {
        return result;
    }

    public static void main(String[] args) throws Exception {
        try {
            throw new IOException("123");
        } catch (Exception e) {
            throw new SuishoudaiException(Result.errorResult, "message", e);
        }
    }

    /*
    * todo 会抛出 SuishoudaiException，并打印堆栈信息及message，
    * todo Caused by: java.io.IOException 并打印IOException的message */
}
